package 力扣;

public class 寻找单一元素540 {
    public static int singleNonDuplicate(int[] nums) {
           int low=1;int high=nums.length;
           int m= 0;
           while (low<high){
               m=low+(high-low)/2;
               if (m%2==0){
                   m--; //保证了查找区间为奇数
               }
               if (nums[m-1]==nums[m]){
                       low=m+2;
               }else
                       high= m;
           }
            return nums[low-1];
    }

    public static void main(String[] args) {
        int []nums={1,1,2,2,3,3,4,4,5,5,6,6,7,8,8,9,9};
        int []nums2={1,1,2,3,3,4,4,8,8};
        int []nums3={1,2,2,3,3};
        int []nums4={3,3,7,7,10,11,11};
        int i = singleNonDuplicate(nums4);
        System.out.println(i);
    }
}